<<<<<<< HEAD
<!--
 * @Author: Xia_cc 978487464@qq.com
 * @Date: 2022-06-08 11:26:41
 * @LastEditors: Xia_cc 978487464@qq.com
 * @LastEditTime: 2022-06-10 10:14:01
 * @FilePath: \vue 小U到家\src\views\Mainzhandianzhanghao.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!--  -->
<template>
  <el-container>
    <!-- 搜索框 -->
    <el-header>
      关键字:<el-input
        class="search"
        type="text"
        placeholder="请输入站点员姓名电话"
        v-model="text"
      ></el-input>
    </el-header>
    <!-- 弹出框 -->
    <el-dialog
      class="psyModle"
      title="添加站点员"
      :visible.sync="zhanDianAddVisible"
      width="37%"
      top="50px"
      center
    >
      <span class="psChaXunSpan">站点员姓名 </span>
      <el-input
        class="searchs"
        type="text"
        placeholder="请输入姓名"
        v-model="zhanDianName"
      ></el-input>
      <span class="psChaXunSpan">站点员电话 </span>
      <el-input
        class="searchs"
        type="text"
        placeholder="请输入电话"
        v-model="zhanDianPhone"
      ></el-input>
      <span class="psChaXunSpan">站点员密码 </span>
      <el-input
        class="searchs"
        type="text"
        placeholder="为空,默认为123456"
        v-model="zhanDianPwds"
      ></el-input>
      <span class="psChaXunSpan">所属站点 </span>
      <el-select v-model="zhanDianZhangHao" class="searchs" placeholder="请选择">
        <el-option
          v-for="item in zhanDianZhangHaoArr"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        >
        </el-option>
      </el-select>
      <span slot="footer" class="dialog-footer">
        <el-button @click="zhanDianAddVisible = false">取 消</el-button>
        <el-button
          type="primary"
          @click="
            zhanDianAddVisible = false;
            add();
          "
          >确 定</el-button
        >
      </span>
    </el-dialog>
    <el-dialog
      class="psyModle"
      title="修改站点员"
      :visible.sync="zhanDianVisible"
      width="37%"
      top="50px"
      center
    >
      <span class="psChaXunSpan">站点员姓名 </span>
      <el-input
        class="searchs"
        type="text"
        placeholder="请输入姓名"
        v-model="zhanDianName"
      ></el-input>
      <span class="psChaXunSpan">站点员电话 </span>
      <el-input
        class="searchs"
        type="text"
        placeholder="请输入电话"
        v-model="zhanDianPhone"
      ></el-input>
      <span class="psChaXunSpan">站点员密码 </span>
      <el-input
        class="searchs"
        type="password"
        placeholder="为空,默认为123456"
        v-model="zhanDianPwds"
        show-password
      ></el-input>
      <span class="psChaXunSpan">所属站点 </span>
      <el-select v-model="zhanDianZhangHao" class="searchs" placeholder="请选择">
        <el-option
          v-for="item in zhanDianZhangHaoArr"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        >
        </el-option>
      </el-select>
      <span slot="footer" class="dialog-footer">
        <el-button @click="zhanDianVisible = false">取 消</el-button>
        <el-button
          type="primary"
          @click="
            zhanDianVisible = false;
            updates();
          "
          >确 定</el-button
        >
      </span>
    </el-dialog>
    <!-- 显示表 -->
    <el-main>
      <el-row>
        <el-button
          @click="
            zhanDianAddVisible = true;
            clears();
          "
          type="primary"
          plain
          >添加</el-button
        >
        <el-button @click="batch()" type="danger" plain>删除</el-button>
      </el-row>
      <Maintable :tableData="zhandianArr">
        <template v-slot:tableline>
          <el-table-column prop="mgr_name" label="站点员姓名" width="220"> </el-table-column>
          <el-table-column prop="mgr_phone" label="联系电话" width="220"> </el-table-column>
          <el-table-column prop="mgr_site" label="所属站点" width="220"> </el-table-column>
          <el-table-column prop="mgr_regTime" label="添加时间" width="220"> </el-table-column>
        </template>
        <template v-slot:chaozuo>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button
                type="primary"
                plain
                icon="el-icon-edit"
                title="编辑"
                @click="
                  zhanDianVisible = true;
                  chakan(scope.row.mgr_id);
                "
              ></el-button>
              <el-button
                type="danger"
                plain
                icon="el-icon-delete"
                title="删除"
                @click="psyDelBut(scope.row.mgr_id)"
              ></el-button>
            </template>
          </el-table-column>
        </template>
      </Maintable>
    </el-main>
    <el-footer>
      <div class="block">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :page-sizes="[6, 8, 10, 12]"
          :page-size="100"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        >
        </el-pagination>
      </div>
    </el-footer>
  </el-container>
</template>

<script>
import Maintable from "../components/main/Maintable";
export default {
  name: "Mainzhandianzhanghao",
  components: {
    Maintable,
  },
  computed: {},
  data() {
    return {
      text: "",
      size: 6,
      page: 1,
      total: 0,
      currentPage: 1,
      zhandianArr: [],
      zhanDianPwds: "",
      zhanDianName: "",
      zhanDianPhone: "",
      zhanDianTime: "",
      zhanDianZhangHao: "青羊区",
      zhanDianVisible: false,
      zhanDianAddVisible: false,
      zhanDianZhangHaoArr: JSON.parse(window.localStorage.getItem("allzhandianArr")),
    };
  },
  methods: {
    //批量删除
    batch() {
      var Arr = JSON.parse(window.localStorage.getItem("val"));
      console.log(Arr);
      this.$axios({
        method: "post",
        url: "/xiaoucomeshome_war/admin/managerDelete",
        data: Arr,
      })
        .then((res) => {
          // console.log(res);
          // this.tableData = res.data.data;
        })
        .catch((err) => {
          console.log(err);
        });
      this.selects();
    },
    handleSizeChange(val) {
      this.size = val;
      console.log(`每页 ${val} 条`);
      this.selects();
    },
    handleCurrentChange(val) {
      this.page = val;
      console.log(`当前页: ${val}`);
      this.selects();
    },
    //清空
    clears() {
      this.zhanDianPwds = "";
      this.zhanDianName = "";
      this.zhanDianPhone = "";
      this.zhanDianZhangHao = "";
    },
    //添加
    add() {
      this.$axios({
        method: "post",
        url: "/xiaoucomeshome_war/admin/addManager",
        data: {
          name: this.zhanDianName,
          phone: this.zhanDianPhone,
          site: this.zhanDianZhangHao,
          pwd: this.zhanDianPwds,
        },
      })
        .then((response) => {
          // console.log(response);
        })
        .catch((error) => {
          console.log(error);
        });
      this.selects();
      // console.log(this.zhanDianZhangHao, this.zhanDianName, this.zhanDianPhone, this.zhanDianPwd);
    },
    updates() {
      var mgr_id = window.localStorage.getItem("mgr_id");
      this.zhandianArr.forEach((element) => {
        if (element.mgr_id == mgr_id) {
          this.$axios({
            method: "post",
            url: "/xiaoucomeshome_war/admin/editManager",
            data: {
              name: this.zhanDianName,
              phone: this.zhanDianPhone,
              site: this.zhanDianZhangHao,
              pwd: this.zhanDianPwds,
            },
          })
            .then((response) => {
              // console.log(response);
              // this.zhandianArr = response.data.data;
            })
            .catch((error) => {
              console.log(error);
            });
        }
      });
      // this.$forceUpdate();
      this.selects();
    },
    psyDelBut(mgr_id) {
      // console.log(mgr_id);
      this.$confirm("此操作将永久删除该数据, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "删除成功!",
          });
          this.deletes(mgr_id);
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
      this.selects();
    },
    deletes(mgr_id) {
      // console.log(id);
      this.$axios({
        method: "post",
        url: "/xiaoucomeshome_war/admin/managerDeleteById",
        params: { mgr_id },
      })
        .then((res) => {
          // console.log(res);
          // this.tableData = res.data.data;
        })
        .catch((err) => {
          // console.log(err);
        });
      this.selects();
    },
    //查看
    chakan(id) {
      window.localStorage.setItem("mgr_id", id);
      this.zhandianArr.forEach((element) => {
        if (element.mgr_id == id) {
          this.zhanDianName = element.mgr_name;
          this.zhanDianPhone = element.mgr_phone;
          // this.zhanDianTime = element.mgr_regTime;
          this.zhanDianZhangHao = element.mgr_site;
          this.zhanDianPwds = element.mgr_pwd;
        }
      });
    },
    //获取页面数据
    selects() {
      this.$axios({
        method: "post",
        url: "/xiaoucomeshome_war/admin/selectManager",
        data: {
          // mgr_phone: "13",
          page: this.page,
          size: this.size,
        },
      })
        .then((response) => {
          this.total = response.data.total;
          this.zhandianArr = response.data.data;
          // console.log(response.data.data);
        })
        .catch((error) => {
          console.log(error);
        });
    },
  },
  mounted() {
    this.selects();
  },
};
</script>

<style lang="less" scoped>
.search {
  margin: 10px 40px 0 20px;
  width: 20%;
}
.block {
  margin: 0 130px;
  float: right;
}
.psChaXunSpan {
  width: 20%;
  display: inline-block;
  margin: 5px 2%;
  text-align-last: justify;
}

.searchs {
  margin: 5px 2%;
  width: 72%;
}
</style>
=======
<!--
 * @Author: Xia_cc 978487464@qq.com
 * @Date: 2022-06-08 11:26:41
 * @LastEditors: Xia_cc 978487464@qq.com
 * @LastEditTime: 2022-06-10 10:14:01
 * @FilePath: \vue 小U到家\src\views\Mainzhandianzhanghao.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!--  -->
<template>
  <el-container>
    <!-- 搜索框 -->
    <el-header>
      关键字:<el-input
        class="search"
        type="text"
        placeholder="请输入站点员姓名电话"
        v-model="text"
      ></el-input>
    </el-header>
    <!-- 弹出框 -->
    <el-dialog
      class="psyModle"
      title="添加站点员"
      :visible.sync="zhanDianAddVisible"
      width="37%"
      top="50px"
      center
    >
      <span class="psChaXunSpan">站点员姓名 </span>
      <el-input
        class="searchs"
        type="text"
        placeholder="请输入姓名"
        v-model="zhanDianName"
      ></el-input>
      <span class="psChaXunSpan">站点员电话 </span>
      <el-input
        class="searchs"
        type="text"
        placeholder="请输入电话"
        v-model="zhanDianPhone"
      ></el-input>
      <span class="psChaXunSpan">站点员密码 </span>
      <el-input
        class="searchs"
        type="text"
        placeholder="为空,默认为123456"
        v-model="zhanDianPwds"
      ></el-input>
      <span class="psChaXunSpan">所属站点 </span>
      <el-select v-model="zhanDianZhangHao" class="searchs" placeholder="请选择">
        <el-option
          v-for="item in zhanDianZhangHaoArr"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        >
        </el-option>
      </el-select>
      <span slot="footer" class="dialog-footer">
        <el-button @click="zhanDianAddVisible = false">取 消</el-button>
        <el-button
          type="primary"
          @click="
            zhanDianAddVisible = false;
            add();
          "
          >确 定</el-button
        >
      </span>
    </el-dialog>
    <el-dialog
      class="psyModle"
      title="修改站点员"
      :visible.sync="zhanDianVisible"
      width="37%"
      top="50px"
      center
    >
      <span class="psChaXunSpan">站点员姓名 </span>
      <el-input
        class="searchs"
        type="text"
        placeholder="请输入姓名"
        v-model="zhanDianName"
      ></el-input>
      <span class="psChaXunSpan">站点员电话 </span>
      <el-input
        class="searchs"
        type="text"
        placeholder="请输入电话"
        v-model="zhanDianPhone"
      ></el-input>
      <span class="psChaXunSpan">站点员密码 </span>
      <el-input
        class="searchs"
        type="password"
        placeholder="为空,默认为123456"
        v-model="zhanDianPwds"
        show-password
      ></el-input>
      <span class="psChaXunSpan">所属站点 </span>
      <el-select v-model="zhanDianZhangHao" class="searchs" placeholder="请选择">
        <el-option
          v-for="item in zhanDianZhangHaoArr"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        >
        </el-option>
      </el-select>
      <span slot="footer" class="dialog-footer">
        <el-button @click="zhanDianVisible = false">取 消</el-button>
        <el-button
          type="primary"
          @click="
            zhanDianVisible = false;
            updates();
          "
          >确 定</el-button
        >
      </span>
    </el-dialog>
    <!-- 显示表 -->
    <el-main>
      <el-row>
        <el-button
          @click="
            zhanDianAddVisible = true;
            clears();
          "
          type="primary"
          plain
          >添加</el-button
        >
        <el-button @click="psyDelBut()" type="danger" plain>删除</el-button>
      </el-row>
      <Maintable :tableData="zhandianArr">
        <template v-slot:tableline>
          <el-table-column prop="mgr_name" label="站点员姓名" width="220"> </el-table-column>
          <el-table-column prop="mgr_phone" label="联系电话" width="220"> </el-table-column>
          <el-table-column prop="mgr_site" label="所属站点" width="220"> </el-table-column>
          <el-table-column prop="mgr_regTime" label="添加时间" width="220"> </el-table-column>
        </template>
        <template v-slot:chaozuo>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button
                type="primary"
                plain
                icon="el-icon-edit"
                title="编辑"
                @click="
                  zhanDianVisible = true;
                  chakan(scope.row.mgr_id);
                "
              ></el-button>
              <el-button
                type="danger"
                plain
                icon="el-icon-delete"
                title="删除"
                @click="psyDelBut(scope.row.mgr_id)"
              ></el-button>
            </template>
          </el-table-column>
        </template>
      </Maintable>
    </el-main>
  </el-container>
</template>

<script>
import Maintable from "../components/main/Maintable";
export default {
  name: "Mainzhandianzhanghao",
  components: {
    Maintable,
  },
  computed: {},
  data() {
    return {
      text: "",
      zhandianArr: [],
      zhanDianPwds: "",
      zhanDianName: "",
      zhanDianPhone: "",
      zhanDianTime: "",
      zhanDianZhangHao: "青羊区",
      zhanDianVisible: false,
      zhanDianAddVisible: false,
      zhanDianZhangHaoArr: [
        {
          value: "青羊区",
          label: "青羊区",
        },
        {
          value: "武侯区",
          label: "武侯区",
        },
        {
          value: "金牛区",
          label: "金牛区",
        },
      ],
    };
  },
  methods: {
    //清空
    clears() {
      this.zhanDianPwds = "";
      this.zhanDianName = "";
      this.zhanDianPhone = "";
      this.zhanDianZhangHao = "";
    },
    //添加
    add() {
      this.$axios({
        method: "post",
        url: "/xiaoucomeshome_war/admin/addManager",
        data: {
          name: this.zhanDianName,
          phone: this.zhanDianPhone,
          site: this.zhanDianZhangHao,
          pwd: this.zhanDianPwds,
        },
      })
        .then((response) => {
          // console.log(response);
        })
        .catch((error) => {
          console.log(error);
        });
      this.selects();
      // console.log(this.zhanDianZhangHao, this.zhanDianName, this.zhanDianPhone, this.zhanDianPwd);
    },
    updates() {
      var mgr_id = window.localStorage.getItem("mgr_id");
      this.zhandianArr.forEach((element) => {
        if (element.mgr_id == mgr_id) {
          this.$axios({
            method: "post",
            url: "/xiaoucomeshome_war/admin/editManager",
            data: {
              name: this.zhanDianName,
              phone: this.zhanDianPhone,
              site: this.zhanDianZhangHao,
              pwd: this.zhanDianPwds,
            },
          })
            .then((response) => {
              // console.log(response);
              // this.zhandianArr = response.data.data;
            })
            .catch((error) => {
              console.log(error);
            });
        }
      });
      // this.$forceUpdate();
      this.selects();
    },
    psyDelBut(id) {
      this.$confirm("此操作将永久删除该数据, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "删除成功!",
          });
          this.deletes(id);
          this.selects();
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    deletes(id) {
      // console.log(id);
      this.$axios({
        method: "post",
        url: "/xiaoucomeshome_war/admin/managerDeleteById",
        data: { mgr_id: id },
      })
        .then((res) => {
          // console.log(res);
          // this.tableData = res.data.data;
        })
        .catch((err) => {
          // console.log(err);
        });
      this.selects();
    },
    //查看
    chakan(id) {
      window.localStorage.setItem("mgr_id", id);
      this.zhandianArr.forEach((element) => {
        if (element.mgr_id == id) {
          this.zhanDianName = element.mgr_name;
          this.zhanDianPhone = element.mgr_phone;
          // this.zhanDianTime = element.mgr_regTime;
          this.zhanDianZhangHao = element.mgr_site;
          this.zhanDianPwds = element.mgr_pwd;
        }
      });
    },
    //获取页面数据
    selects() {
      this.$axios({
        method: "post",
        url: "/xiaoucomeshome_war/admin/selectManager",
        data: {
          // mgr_phone: "13",
          page: 1,
          size: 10,
        },
      })
        .then((response) => {
          this.zhandianArr = response.data.data;
          // console.log(response.data.data);
        })
        .catch((error) => {
          console.log(error);
        });
    },
  },
  mounted() {
    this.selects();
  },
};
</script>

<style lang="less" scoped>
.search {
  margin: 10px 40px 0 20px;
  width: 20%;
}

.psChaXunSpan {
  width: 20%;
  display: inline-block;
  margin: 5px 2%;
  text-align-last: justify;
}

.searchs {
  margin: 5px 2%;
  width: 72%;
}
</style>
>>>>>>> ae27e4fe2d4f939d0b0ee2bfa506b9e3269c53cb
